﻿using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Dto.Output.DeathModelsOutPut;
using IntelligentAgriculture.Contracts.Dto.Output.EarTagOutput;
using IntelligentAgriculture.Contracts.Dto.Output.PageOutput;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.DeathModelCommand;
using IntelligentAgriculture.WebAPI.Application.Command.EarTageCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.DeathModelCommandJamdier
{
    public class DeathEagShowCommandHandler : IRequestHandler<DeathEagShowCommand, Results<PagesOutput<DeathModelsOutPut>>>
    {
        private readonly iDeathModelService _iDeathModelService;

        public DeathEagShowCommandHandler(iDeathModelService deathModelService)
        {
            _iDeathModelService = deathModelService;
        }
        /// <summary>
        /// 显示，查询，分页
        /// </summary>
        /// <param name="request">查询条件</param>
        /// <param name="cancellationToken"></param>
        /// <returns>返回列表</returns>
        public async Task<Results<PagesOutput<DeathModelsOutPut>>> Handle(DeathEagShowCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _iDeathModelService.GetShow(request.Death);
                var results = Results<PagesOutput<DeathModelsOutPut>>.DataResult(list);
                return results;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
